package com.du.ssm.controller;

import com.du.ssm.pojo.Department;
import com.du.ssm.pojo.Message;
import com.du.ssm.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author : DuJiabao
 * @Project : ssm
 * @Time : 2021/4/12 15:53
 * @Desc :
 */
@Controller
public class DepartmentController {
  DepartmentService departmentService;

  @ResponseBody
  @RequestMapping("/deps")
  public Message getDepsWithJson() {
    List<Department> departments = departmentService.getAllDepartments();
    return Message.getSuccessMessage().add("deps", departments);
  }

  @Autowired
  public void setDepartmentService(DepartmentService departmentService) {
    this.departmentService = departmentService;
  }
}
